﻿//using InternetSpiderLib;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using WeChatGZHTextExtractor.DB;

//namespace WeChatGZHTextExtractor.BusinessCreaters
//{
//    public class BC_ExistingAccountUrl : IBusinessCreater
//    {
//        private SceneManager _SceneManager;

//        public BC_ExistingAccountUrl()
//        {
//            _SceneManager = SingleCase.Get<SceneManager>();
//        }

//        public Action Create()
//        {
//            //var db_context = SingleCase.Get<WxDataContext>();
//            //var model = db_context.WXAccount.Where(n => n.Monitor).Where(n => n.LastTime + n.Interval < Timestamp.Now).Where(n => !string.IsNullOrEmpty(n.Url)).FirstOrDefault();

//            var accounte_service = new BaseService<WXAccountModel>();
//            var model = accounte_service.Query(context => context.Where(n => n.Monitor).Where(n => n.LastTime + n.Interval < Timestamp.Now).Where(n => !string.IsNullOrEmpty(n.Url)).FirstOrDefault());

//            if (model == null)
//                return null;

//            model.LastTime = Timestamp.Now;
//            //db_context.SaveChanges();
//            accounte_service.Change();

//            return () =>
//            {
//                var url = model.Url;

//                LogHelper.GetInstance().Log(LogType.Info, url);

//                var body = HttpHelper.HttpGet(url);

//                _SceneManager.TriggerScene(new DataBox()
//                    .Set<string>(PublicKey.EventType.EVENT_NAME, PublicKey.EventType.HTTP_GET)
//                    .Set(model)
//                    .Set<string>(PublicKey.HtmlInfo.URL, url)
//                    .Set<string>(PublicKey.HtmlInfo.BODY, body));
//            };
//        }
//    }
//}
